from zope.interface import Interface
from zope import schema
from zope.i18nmessageid import MessageFactory
from zope.component.interfaces import IObjectEvent

_ = MessageFactory(u"ownio.url.interfaces")

class IUrlSettingsUtility(Interface):
    """
    This adapter is used for basic short url manipulation, 
    like generating a new short url code.
    """

class IUrlSettings(Interface):
    """
    This interface is used for form variables by the control
    panel configlet.
    """
    
    domain = schema.TextLine(
            title=_(u"Domain"),
            description=_(u"The short URL domain. This will be used for redirection."),
            required=True,
            default=u"own.io"
    )
    
    seed = schema.TextLine(
            title=_(u"Seed"),
            description=_(u"The short URL seed. Please be careful with this setting."),
            required=True,
            default=u'a'
    )
    
    shortUrlContent = schema.Set(
            title=_(u"Short URL content"),
            description=_(u"Specify content that should have a short url by portal_type|attr. Example: Link|getRemoteUrl"),
            required=False,
            default=set([u"Link|getRemoteUrl"]),
            value_type=schema.TextLine(title=_(u"Content")),
    )

class IShortUrl(Interface):
    """
    Marker interface for content with a short URL. Content objects that support
    and are setup to have short urls, are marked with this interface.
    """

class IShortUrlAdapter(Interface):
    """
    This is the adapted version of objects that provide the IShortUrl
    interface.
    """

class IAddedShortUrlEvent(IObjectEvent):
    """
    This marker interface used by the events module. When first a short url 
    supported object is initiated, the first time annotation occurrs and then
    this event is invoked.
    """
    